package com.group02.community.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group02.community.entity.user.SysRoleMenu;
import com.group02.community.mapper.RoleMenuMapper;
import com.group02.community.service.IRoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, SysRoleMenu> implements IRoleMenuService {
    @Autowired
    RoleMenuMapper roleMenuMapper;

    @Override
    public List<Long> getRoleMenuIdsById(Long id) {

        List<SysRoleMenu> roleMenu=roleMenuMapper.selectRoleMenuById(id);
        List<Long> menuIdList = roleMenu.stream().map(menu -> menu.getMenuId()).collect(Collectors.toList());
        List<Long> list = menuIdList.stream().filter(a -> a >= 1000).collect(Collectors.toList());
        return list;
    }

    @Override
    public void deleteByAllRoleId(Long id) {
        roleMenuMapper.deleteByAllRoleId(id);
    }
}
